package com;

import com.alibaba.fastjson.JSON;
import com.bean.WXPayBean;
import com.homegoods.classify.model.Constant;
import com.network.retrofit_rx.Api.ActionSubscriber;
import com.network.retrofit_rx.Api.CommandImpl;
import com.network.retrofit_rx.Api.HttpManager;

import org.json.JSONObject;

import java.util.List;

import io.reactivex.functions.Consumer;

public class PayApiUtils {
    /**
     * 添加订单
     * cmd=Payorder          //方法名
     * token=000             //token身份验证
     * orderlist=['x','y']  //订单的sid，传json格式的字符数组
     * paytype=alipay  //支付方式传alipay为支付宝支付，传weixin为微信支付
     */
//    public static void orderPay(List<String> orderList, String payType, Consumer<WXPayBean> consumer, Consumer<Throwable> error) {
//        CommandImpl command = new CommandImpl.Builder()
//                .setUrl(Constant.SERVER_URL + Constant.SIMPLE_PLAN_CMD)
//                .addParams("cmd", "Payorder")
//                .addParams("token", HomeGoodsApp.getToken())
//                .addParams("orderlist", JSON.toJSON(orderList))
//                .addParams("paytype", payType)
//                .setObject(true)
//                .setClass(WXPayBean.class)
//                .create();
//        HttpManager.getInstance().get(command, new ActionSubscriber<>(consumer, error, null));
//    }

    public static void orderPay(List<String> orderList, String payType, Consumer<WXPayBean> consumer, Consumer<Throwable> error) {
        CommandImpl command = new CommandImpl.Builder()
                .setUrl(Constant.SERVER_URL + "/AMAPI/AlPayByWeb.aspx")
                .setObject(true)
                .setClass(WXPayBean.class)
                .create();
        HttpManager.getInstance().get(command, new ActionSubscriber<>(consumer, error, null));
    }


}
